package Eyjafjalla.action;

import Eyjafjalla.card.status.Cloud_Eyjafjalla;
import Eyjafjalla.power.RedCloudPower;
import Eyjafjalla.power.WhiteCloudPower;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.actions.common.GainEnergyAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.core.Settings;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.ui.panels.EnergyPanel;

public class LittleFeelingsAction extends AbstractGameAction {
    public LittleFeelingsAction(AbstractCreature target, boolean freeToPlayOnce, int energyOnUse, int extraAmount,boolean isFire){
        this.extra = extraAmount;
        this.target = target;
        this.freeToPlayOnce = freeToPlayOnce;
        this.duration = Settings.ACTION_DUR_XFAST;
        this.actionType = ActionType.ENERGY;
        this.energyOnUse = energyOnUse;
        p = AbstractDungeon.player;
        this.isFire = isFire;
    }

    boolean isFire;
    private boolean freeToPlayOnce = false;
    private AbstractPlayer p;
    private int energyOnUse;
    int extra;

    @Override
    public void update() {
        int effect = EnergyPanel.totalCount;
        if (this.energyOnUse != -1) {
            effect = this.energyOnUse;
        }

        if(effect>0&&isFire){
            addToTop(new GainEnergyAction(1));
        }

        if (this.p.hasRelic("Chemical X")) {
            effect += 2;
            this.p.getRelic("Chemical X").flash();
        }

        effect+=extra;

        if (effect > 0) {
            addToTop(new ApplyPowerAction(target,p,new WhiteCloudPower(target,effect),effect));
            addToTop(new ApplyPowerAction(target,p,new RedCloudPower(target,effect),effect));
            if (!this.freeToPlayOnce) {
                this.p.energy.use(EnergyPanel.totalCount);
            }
        }

        this.isDone = true;
    }
}

